package org.gdufe.bookCollections.config;



import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("org.gdufe.bookCollections.mapper")
public class MyBatisPlusConfig {

    @Bean //配置分页插件(拦截器)
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    @Bean
    // SQL 执行性能分析，开发环境使用，线上不推荐。
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        // maxTime 指的是 sql 最大执行时长, 单位为ms
        performanceInterceptor.setMaxTime(100);
        // SQL是否格式化 默认为true
        performanceInterceptor.setFormat(true);
        return performanceInterceptor;
    }

}
